<?php

namespace application\model;

use application\entity\db\AdministratorRole;
use application\model\BaseModel;

class AdministratorRoleModel extends BaseModel {

    public function __construct() {
        parent::__construct(AdministratorRole::class);
    }

    /**
     * Xóa role theo admin id
     * @param type $id
     * @return type
     */
    public function deleteByAdministratorId($id) {
        $cri = new \core\entity\Criteria();
        $cri->andKey("administratorId")->is($id);
        return $this->idelete($cri);
    }

    /**
     * Danh sách quyền theo admin id
     * @param type $id
     * @return type
     */
    public function getRoleByAdministratorId($id) {
        $cri = new \core\entity\Criteria();
        $cri->andKey("administratorId")->is($id);
        $query = new \core\entity\Query($cri);
        return $this->ifind($query);
    }

}
